package com.lavender.annotation._async;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.concurrent.Future;

@Component
public class TestAsyncCommand implements CommandLineRunner {

    @Autowired
    private TestService service;

    @Override
    public void run(String... args) throws Exception {
        // 1
        //service.hello1();
        //System.out.println("time is " + LocalDateTime.now().toString() + ", test hello1.");

        // 2
        Future<String> future = service.hello2();
        System.out.println("time is " + LocalDateTime.now().toString() + ", " + future.get());
    }

}
